package com.his.entity;

import com.his.common.Const;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.validation.constraints.*;
import javax.validation.groups.Default;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * (HisUser)实体类
 *
 * @author makejava
 * @since 2020-10-23 18:09:49
 */
@Data
@NoArgsConstructor
@ToString
@AllArgsConstructor
public class HisUser implements Serializable {
    private static final long serialVersionUID = -21221512258327659L;

    @NotNull(message = "用户id不能为空", groups = {Const.UpdateUserStatus.class})
    private Integer id;

    @NotBlank(message = "账号不能为空", groups = {Const.LoginGroup.class, Default.class})
    @Pattern(regexp = "^\\w{3,10}$"
            , message = "账号的长度为3-10位字母数字下划线组成")
    private String account;

    @NotBlank(message = "密码不能为空", groups = {Const.LoginGroup.class, Default.class})
    @Pattern(regexp = "^\\S{4,10}$", message = "密码长度为4-10位非空字符组成")
    private String password;

    @NotBlank(message = "姓名不能为空")
    private String realName;

    @NotBlank(message = "性别不能为空")
    @Pattern(regexp = "^[0,1]$", message = "性别只能为0或1,0代表女")
    private String gender;

    @NotNull(message = "年龄不能为空")
    @Min(1)
    @Max(99)
    private Integer age;

    @NotBlank(message = "邮箱不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$",
            message = "邮箱格式不正确")
    private String email;

    @NotBlank(message = "地址不能为空")
    @Pattern(regexp = "^\\S{4}$", message = "地址最少长度为4位")
    private String address;

    @NotBlank(message = "号码不能为空")
    @Pattern(regexp = "^1[0-9]{10}$", message = "手机号码格式不正确")
    private String tellphone;

    private Date creatTime;

    private Date updateTime;

    private String isDelete;

    private List<String> roles;

    private String roleName;

    @NotNull(message = "修改的用户状态不能为空", groups = {Const.UpdateUserStatus.class})
    private String status;

    @NotNull(message = "角色不能为空")
    private Integer roleId;

    @NotNull(message = "角色科室不能为空")
    private Integer depId;

    private String depName;

    public HisUser(Integer id, String status) {
        this.id = id;
        this.status = status;
    }
}
